<?php
class IsRecentBehavior extends CActiveRecordBehavior {
	public $dateAttribute = 'createTime';
	public $dateFormat = 'yyyy-MM-dd hh:mm:ss';
	public $validRecentDays = 7;

	public function getIsRecent() {
		$dateValue = $this->getOwner()->{$this->dateAttribute};
		$date = CDateTimeParser::parse($dateValue, $this->dateFormat);
		$diff = time() - $date;
		if ($diff < $this->validRecentDays * 86400) {
			return true;
		} else {
			return false;
		}
	}

}
